package com.atliuzu.utils;

import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Author : songyuan
 * @Description :
 * Date : 2022/7/31 9:28
 * @Version : 1.0
 */
public class ThreadPoolUtil {

    private static ThreadPoolExecutor threadPoolExecutor = null;


    private ThreadPoolUtil() {
    }

    ;


    public static ThreadPoolExecutor getThreadPoolExecutor() {
        if (threadPoolExecutor == null) {
            synchronized (ThreadPoolUtil.class) {
                if (threadPoolExecutor == null) {
                    threadPoolExecutor = new ThreadPoolExecutor(
                            4,
                            20,
                            5,
                            TimeUnit.MINUTES,
                            new LinkedBlockingDeque<>()
                    );
                }
            }
        }
        return threadPoolExecutor;
    }

}
